Skip to content

Implement ATA DMA and fix DBDMA resCount calculation#191

Merged
dingusdev merged 3 commits into
dingusdev:masterfrom
mihaip:upstream-ata-dma
Jul 7, 2026
Merged

Implement ATA DMA and fix DBDMA resCount calculation#191
dingusdev merged 3 commits into
dingusdev:masterfrom
mihaip:upstream-ata-dma

Conversation

@mihaip

@mihaip mihaip commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Three commits, see the individual commit messages for details (should not be squashed when merging):

  1. Implement ATA DMA
  2. Fix resCount to return the "residual" value, which matches the CHRP spec and xnu implementation
  3. Demote a somewhat spammy log line that does not actually constitute a warning/error

Fixes #154

@mihaip mihaip marked this pull request as draft July 6, 2026 02:42
@mihaip

mihaip commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

(moving back to draft - I must have broken something while preparing this for upstreaming and the 10.0 beta still hangs)

Edit: should work now - there was a "magic" timeout needed for assert_dmareq - added a TODO since the more correct fix is invasive.

mihaip added 3 commits July 5, 2026 21:45
Handle ATA DMA reads and writes for hard disks. Reads prepare data from
the backing image and writes accept pushed data from the DBDMA channel
until the programmed sector count is exhausted.

The `data_ptr` in `AtaBaseDevice` needs to be advanced after each DMA
pull so one request can be split across multiple DBDMA descriptors.
We were treating resCount as a "result" count, but it's actually a "residual"
count that reports how many bytes from a descriptor were not transferred
when processing a command. We now correctly handle partial descriptors.

This ended up being necessary for the 10.0 public beta bringup too (the
`AppleUltra66ATA::stopDma` implementation in xnu-103 computes the number
of bytes transferred by subtracting `resCount` from `reqCount`).
Mac OS X Public Beta commonly drives one ATA DMA transfer through
multiple DBDMA descriptors, so a single ATA pull can be smaller or larger
than the current descriptor request without indicating an error.

Reduce the logging level to avoid logspam during boot.
@mihaip mihaip force-pushed the upstream-ata-dma branch from 5b5d56f to d29153f Compare July 6, 2026 04:56
@mihaip mihaip marked this pull request as ready for review July 6, 2026 04:59
@dingusdev dingusdev merged commit 0dfc30c into dingusdev:master Jul 7, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Mac OS X Public Beta does not boot

2 participants